﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;

namespace Kinlo.UI.Main.Converter
{
    public class ResultBackgroundConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                if (value is null)
                {
                   return DependencyProperty.UnsetValue; 
                }
                if (value.ToString().ToUpper() == "TRUE" || value.ToString().ToUpper() == "OK")
                {
                    return Brushes.Green;
                }
                else if (value.ToString().ToUpper() == "FALSE" || value.ToString().ToUpper() == "NG")
                {
                    return Brushes.Red;
                }
                else
                {
                    return DependencyProperty.UnsetValue;
                }
            }
            catch (Exception ex)
            {
                return DependencyProperty.UnsetValue;
                throw ex;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
